package cn.good.payment.service;

import cn.good.mapper.OrderMapper;
import cn.good.mapper.ServicePriceMapper;
import cn.good.pojo.Order;
import cn.good.pojo.ServicePrice;
import cn.good.service.OrderService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service(interfaceClass = OrderService.class)
@Component
public class OrderServiceImpl implements OrderService {

    @Resource
    private OrderMapper orderMapper;
    @Resource
    private ServicePriceMapper servicePriceMapper;

    /**
     * 查询订单信息
     * @param id
     * @return
     */
    @Override
    public Order searchOrderById(Long id) {
        return orderMapper.selectByPrimaryKey(id);
    }

    /**
     * 生成订单
     * @param order
     * @return
     */
    @Override
    public boolean saveOrder(Order order) {
        return false;
    }

    /**
     * 查询订单列表
     * @param map
     * @return
     */
    @Override
    public List<Order> searchListByUserId(Map map) {
        return orderMapper.selectListByMap(map);
    }

    /**
     * 查询订单数量
     * @param map
     * @return
     */
    @Override
    public int searchListCount(Map map) {
        return orderMapper.selectListCountByMap(map);
    }

    /**
     * 根据主键查询医生的对应服务
     * @param id
     * @return
     */
    @Override
    public ServicePrice searchInfoById(Long id) {
        return servicePriceMapper.selectByPrimaryKey(id);
    }

    /**
     * 修改订单状态
     * @param id
     * @return
     */
    @Override
    public int updateOrderById(Long id,Integer orderStatus) {
        return 0;
    }

    /**
     * 根据订单号修改订单状态
     * @param map
     * @return
     */
    @Override
    public int updateOrderByOrderNo(Map map) {

      return   orderMapper.updateByOrderNo(map);

    }

    /**
     * 根据编号查询订单
     * @param orderNo
     * @return
     */
    @Override
    public Order searchOrderByOrderNo(String orderNo) {
        return orderMapper.selectOrderByOrderNo(orderNo);
    }

}
